[mirrors]
http://ftp.barfooze.de/pub/butch/butch-0.5.0.tar.bz2
http://foss.aueb.gr/mirrors/linux/butch/butch-0.5.0.tar.bz2

[main]
filesize=55660
sha512=c0565c79d937e5e971fbb78b8b68b80f2583949bd6d3256e2a7c538707d772cd4801b431903539d9b8c1ce57fc7cc0c63d633e9a931915e3821a799ee12e9805

[deps.host]
stage0_musl

[build]
# set environment variable BUTCH_FROM_GIT to 1 if you want to test the latest butch
if [ ! -z "$BUTCH_FROM_GIT" ] ; then
	rm -rf butch
	git clone https://github.com/sabotage-linux/butch
else
	patch -p1 < "$K"/butch_050-tarball-missing.patch
fi

# prepare build config...
printf "LDFLAGS += -static %s\n" "$optldflags" > butch/config.mak
printf "CFLAGS += %s\n" "$optcflags" >> butch/config.mak

if [ "$A" = "arm" ] || [ "$A" = "mips" ] ; then
	# if on arm or mips, we only use one build thread to not exhaust memory
	sed -i \
	  's@#define NUM_BUILD_THREADS 2@#define NUM_BUILD_THREADS 1@' butch/butch.c
	# do not check checksum, since it can take ages on machines that slow	
	echo "CFLAGS += -DDISABLE_CHECKSUM" >> butch/config.mak
fi

# and build
[ "$STAGE" = "0" ] && CC="$butch_root_dir"/bin/musl-gcc
CC="$CC -static" ./build.sh
BUTCH_BIN=butch/butch
mv "$BUTCH_BIN" "$BUTCH_BIN"-core

# "make install"
dest=$butch_install_dir$butch_prefix
mkdir -p "$dest"/bin
cp -f "$BUTCH_BIN"-core "$dest"/bin/butch-core


